﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GetEmailAttachment
{
    public partial class ucPrgWaiting : UserControl
    {
        private string m_CountStr = "{0}/{1}";
        private Action m_Act = null;
        public ucPrgWaiting()
        {
            InitializeComponent();
            Maximum = 0;
            Value = 0;
            //m_Act = act;
        }
        public Action CancelAction { set { m_Act = value; } }
        public int Maximum
        {
            get { return prgWaiting.Maximum; }
            set
            {
                prgWaiting.Maximum = value;
                lblCancel.Visible = false;
                SetCountTxt();
            }
        }
        public int Value
        {
            get { return prgWaiting.Value; }
            set
            {
                prgWaiting.Value = value;
                SetCountTxt();
            }
        }
        private void SetCountTxt()
        {
            lblCount.Text = string.Format(m_CountStr, Value, Maximum);
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            lblCancel.Visible = true;
            m_Act?.Invoke();
        }
    }
}
